package com.ruoyi.api.apkVersion.entity;


import javax.servlet.http.HttpServletResponse;
import java.io.*;

public class FileUtils {
  public static void download(String filePath, HttpServletResponse res) throws IOException {
    // 发送给客户端的数据
    File file = new File(filePath);
    if(null!=file&&file.exists()){
      OutputStream outputStream = res.getOutputStream();
      byte[] buff = new byte[1024];
      BufferedInputStream bis = null;
      // 读取filename
      bis = new BufferedInputStream(new FileInputStream(file));
      int i = bis.read(buff);
      while (i != -1) {
        outputStream.write(buff, 0, buff.length);
        outputStream.flush();
        i = bis.read(buff);
      }
    }

  }

}
